package com.gujiangbo.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AnnHelloController {

    @SentinelResource(value = "Sentinel_Ann", blockHandler = "exceptionHandler")
    @GetMapping("ann")
    public String hello() {
        return "this is sentinel annotation say Hello World !!";
    }

    /**
     * 自定义降级处理
     *
     * @param blockException
     * @return
     */
    public String exceptionHandler(BlockException blockException) {
        blockException.printStackTrace();
        return "系统繁忙，请稍后再试！";
    }
}
